<?php
// 1\2\
$link=mysqli_connect("127.0.0.1",'root','123456','company');
// 3
$query="select * from department;";
$result=mysqli_query($link, $query);
// 4
while ($row=mysqli_fetch_assoc($result)){
	$rows[]=$row;
}

// 5
mysqli_close($link);


// var_dump($rows);

?>

<html>

	<head>
	
	</head>

	<body>
		<a href="add.php">新增</a>
		<table border="1">
			<tr>
				<th>部门编号</th>
				<th>部门名称</th>
				<th>部分描述</th>
				<th></th>
			</tr>
			
			<?php foreach ($rows as $key=>$value){?>
			
			<tr>
				<td><?php echo $rows[$key]['id']?></td>
				<td><?php echo $rows[$key]['name']?></td>
				<td><?php echo $rows[$key]['description']?></td>
				<td>
					<a href="update.php?id=<?php echo $rows[$key]['id']?>">更新</a>
					<a href="delete.php?id=<?php echo $rows[$key]['id']?>">删除</a>
				
				</td>
			</tr>
			
			<?php }?>	
		</table>
	</body>


</html>










